*** Analysis for efficacy-paper****

**Use sample 1***
use "C:\Users\au278387\Dropbox (Dept of Pol Science)\Artikler\Bureaucratic Efficacy\Data 260918\New samples\Sample 1.dta"

** Bureaucratic self-efficacy***

// Recode reversed order//
recode Q18_6 (1=5)(2=4)(3=3)(4=2)(5=1)

recode Q18_7 (1=5)(2=4)(3=3)(4=2)(5=1)

recode Q18_8 (1=5)(2=4)(3=3)(4=2)(5=1)

recode Q18_9 (1=5)(2=4)(3=3)(4=2)(5=1)

//Factor analysis//
factor Q18_1 Q18_4 Q18_6 Q18_3 Q18_8 Q18_7 Q18_9, pcf
rotate, oblimin(0) oblique

**USE SAMPLE 2 CFA***


// Recode reversed order//
recode Q18_6 (1=5)(2=4)(3=3)(4=2)(5=1)

recode Q18_7 (1=5)(2=4)(3=3)(4=2)(5=1)

recode Q18_8 (1=5)(2=4)(3=3)(4=2)(5=1)

recode Q18_9 (1=5)(2=4)(3=3)(4=2)(5=1)


// CFA //

generate q18_1 = Q18_1  
generate q18_4 = Q18_4 
generate q18_6 = Q18_6
generate q18_3 = Q18_3
generate q18_7 = Q18_7
generate q18_9 = Q18_9
generate q18_8 = Q18_8


sem (RULES -> q18_1 q18_4 q18_6) (ARGUE -> q18_3 q18_7 q18_8 q18_9), stand
estat gof, stats (all)  

**uden q18_3***
sem (RULES -> q18_1 q18_4 q18_6) (ARGUE ->  q18_7 q18_8 q18_9), stand
estat gof, stats (all) 
//langt bedre fit uden q18_3 // 


///FULL SAMPLE///
use "C:\Users\au278387\Dropbox (Dept of Pol Science)\Artikler\Bureaucratic Efficacy\Data 260918\New samples\Full sample.dta" 

// Recode reversed order//
recode Q18_6 (1=5)(2=4)(3=3)(4=2)(5=1)

recode Q18_7 (1=5)(2=4)(3=3)(4=2)(5=1)

recode Q18_8 (1=5)(2=4)(3=3)(4=2)(5=1)

recode Q18_9 (1=5)(2=4)(3=3)(4=2)(5=1) 

//Sum index // 

generate rules =((Q18_1+Q18_4+Q18_6)/3) //går fra 1-5

generate rules10 = (rules-1)/4*10 //går fra 0-10

generate argue =((Q18_7+Q18_8+Q18_9)/3) //går fra 1-5

generate argue10 = (argue-1)/4*10 //går fra 0-10

generate BSE =((Q18_1+Q18_4+Q18_6+Q18_7+Q18_8+Q18_9)/6) 
//går fra 1-5

generate BC10 = (BSE-1)/4*10 //går fra 0-10

//CRONBACH ALPHA//
alpha Q18_1 Q18_4 Q18_6, item casewise

alpha Q18_7 Q18_8 Q18_9, item casewise

alpha Q18_1 Q18_4 Q18_6 Q18_7 Q18_8 Q18_9, item casewise


////OTHER VARIABLES////

*General efficacy (GSE)*

generate GSE =((Q22_1+Q22_2+Q22_3+Q22_4+Q22_5+Q22_6+Q22_7+Q22_8+Q22_9+Q22_10)) //10-40
generate GSE10 =((GSE-10)/(40-10))*(10-0)+0 


//Control //

generate gender = Q1
recode gender (2=0) (1=1) //FEMALE = 1)

generate age = year-Q2

generate ethnicity = Q27 //HUSK at gå disse igennem og ændre //
recode ethnicity (2=0) //Danish = 1//

generate education = Q23
recode education (6=0)

generate experience = Q12
recode experience (1=0) (2=1) (3=2) (4=3) (5=4) (6=5) (7=6) (8=7) (9=8) (10=9)(11=10) (12=11) (13=12) (14=13)(15=14)(16=15) (17=16)(18=17) (19=18) (20=19) (21=20) (22=21)

generate experience_dummy = Q12
recode experience_dummy (1=0) (2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 =1)

generate localSA = Q7

generate off_pri = Q25
recode off_pri = (1=0) (2=1) (3=.) /// 0 = erfaring fra det private 1 = erfaring fra det offentlige /// 

generate ansoeger = Q11 // 1 = ansøger, 2) ekspartner ansøger, 3) begge
recode ansoeger(4=.)

generate aftale_afg = Q1_2_r2
recode aftale_afg (2=0)

//LEGAL ROLE///
generate legalrole = Q4
recode legalrole (2=0) //bopælsforælder = 1, samværforælder = 0

//Dummies for localSA//
tabulate localSA, generate(d)

tabulate education, generate(edu)

///PWCORR//

///REGRESSIONS//
reg PJ BSE 
reg PJ BSE gender age ethnicity
reg PJ BSE gender age ethnicity GSE10

reg PJ rules 
reg PJ rules gender age ethnicity
reg PJ rules gender age ethnicity GSE10

reg PJ argue 
reg PJ argue gender age ethnicity
reg PJ argue gender age ethnicity GSE10

reg fairness BSE 
reg fairness BSE gender age ethnicity
reg fairness BSE gender age ethnicity GSE10

reg fairness rules 
reg fairness rules gender age ethnicity
reg fairness rules gender age ethnicity GSE10

reg fairness argue 
reg fairness argue gender age ethnicity
reg fairness argue gender age ethnicity GSE10 




***************************************************************
* ANALYSER MED SKEMA 2 OG 3*
***************************************************************

generate T1_sam = Q14
recode T1_sam (1=0) (2=1) (3=2)(4=3)(5=4)(6=5)(7=6)(8=7)(9=8)(10=9)(11=10)(12=11) (13=12) (14=13) (15=14)(16 = .a)

generate T1_sam_forklaring = Q14a

////T2v ///

recode Q3_2_r2(1=0)(2=1)(3=2)(4=3)(5=4)(6=5)(7=6)(8=7)(9=8)(10=9)(11=10)(12=11) (13=12) (14=13) (15=14)(16 = .a)
recode Q4_r3(1=0)(2=1)(3=2)(4=3)(5=4)(6=5)(7=6)(8=7)(9=8)(10=9)(11=10)(12=11) (13=12) (14=13) (15=14)(16 = .a)

generate T2_sam = .
replace T2_sam = T1_sam if	Q2_2_r2 == 2
replace T2_sam = Q3_2_r2 if Q2_2_r2 == 1
replace T2_sam = T1_sam if	Q3_r3 == 2
replace T2_sam = Q4_r3 if Q3_r3 == 1

//Forklaring//

generate skema2 = Q4_2_r2
generate skema3 = Q5_r3


///Ændring fra T1 til T2///

generate sam_diff = (T2_sam-T1_sam)


//PROCEDUAL JUSTICE///
factor Q25_1_2_r2 Q25_2_2_r2 Q25_3_2_r2 Q25_4_2_r2 Q25_5_2_r2 Q25_6_2_r2 Q25_7_2_r2 Q25_8_2_r2 Q25_9_2_r2 Q25_10_2_r2, pcf
recode Q25_1_2_r2 Q25_2_2_r2 Q25_3_2_r2 Q25_4_2_r2 Q25_5_2_r2 Q25_6_2_r2 Q25_7_2_r2 Q25_8_2_r2 Q25_9_2_r2 Q25_10_2_r2 (6=.)

generate PJ =((Q25_1_2_r2+Q25_2_2_r2+Q25_3_2_r2+Q25_4_2_r2+Q25_5_2_r2+Q25_6_2_r2+Q25_7_2_r2+Q25_8_2_r2+Q25_9_2_r2+Q25_10_2_r2)/10)

//Aftalen/afgørelsen er fair//
generate fairness = .
replace fairness = Q6_2_r2 if Q1_2_r2 == 1
replace fairness = Q7_r3 if Q1_2_r2 == 2
recode fairness (1=0) (2=1) (3=2) (4=3) (5=4) (6=5) (7=6) (8=7) (9=8) (10=9) (11=10)


///NYE VARIABLE - OUTCOMES//

//ØNSKE I T1///
recode Q15 (15=.)

generate oensk_t1 = .
replace oensk_t1 = T1_sam if Q13 ==1
replace oensk_t1 = Q15 if Q13 ==2

generate oensk_forklar = Q15a


//FORSKEL MELLEM T1 OG ØNSKE//
generate t1_oensk_diff = (oensk_t1-T1_sam)

recode t1_oensk_diff (-12=12) (-11=11) (-10=10) (-9=9) (-8=8) (-7=7) (-6=6) (-5=5) (-4=4) (-3=3) (-2=2) (-1=1) 

//FORSKEL MELLEM T2 OG ØNSKE//

generate t2_oensk_diff = (oensk_t1-T2_sam)

recode t2_oensk_diff (-12=12) (-11=11) (-10=10) (-9=9) (-8=8) (-7=7) (-6=6) (-5=5) (-4=4) (-3=3) (-2=2) (-1=1) 

generate outcome_dummy = t2_oensk_diff
recode outcome_dummy (1 2 3 4 5 6 6 7 8 9 10 11 12 13 14 = 0) (0=1)

/// FÅR ALT ///
generate dummy_alt = .
replace dummy_alt = 1 if t2_oensk_diff ==0
replace dummy_alt = 0 if t2_oensk_diff !=0

//FÅR MERE //

generate dummy_mere = .
replace dummy_mere = 1 if t1_oensk_diff>t2_oensk_dif & t2_oensk_dif!=0
replace dummy_mere = 0 if T1_sam==T2_sam & oensk_t1!=T1_sam 


///DUMMIES///

**Ønsker mere**
generate dummy_pref_more = .
replace dummy_pref_more = 1 if oensk_t1>T1_sam
replace dummy_pref_more = 0 if oensk_t1<=T1_sam

**Ønsker mindre**
generate dummy_pref_less = .
replace dummy_pref_less= 1 if oensk_t1<T1_sam
replace dummy_pref_less= 0 if oensk_t1>=T1_sam

**Ønsker status quo**
generate dummy_pref_sq = .
replace dummy_pref_sq = 1 if t1_oensk_diff == 0
replace dummy_pref_sq = 0 if t1_oensk_diff != 0



///MODELLER /// Decision outcome //

reg t2_oensk_diff BC10_ny gender age ethnicity i.education experience i.localSA off_pri aftale_afg t1_oensk_diff SDB

reg t2_oensk_diff rules10 gender age ethnicity i.education experience i.localSA off_pri aftale_afg t1_oensk_diff SDB

reg t2_oensk_diff argue10 gender age ethnicity i.education experience i.localSA off_pri aftale_afg t1_oensk_diff SDB


///MODELLER /// <Procedual justice ///

reg PJ BC10_ny gender age ethnicity i.education experience i.localSA off_pri aftale_afg t2_oensk_diff t1_oensk_diff SDB

reg PJ rules10 gender age ethnicity i.education experience i.localSA off_pri aftale_afg t2_oensk_diff t1_oensk_diff SDB

reg PJ argue10 gender age ethnicity i.education experience i.localSA off_pri aftale_afg t2_oensk_diff t1_oensk_diff SDB


//Robusthed //

reg t2_oensk_diff BC10_ny gender age ethnicity i.education experience i.localSA off_pri aftale_afg t1_oensk_diff SDB if dummy_pref_more ==1
reg t2_oensk_diff BC10_ny gender age ethnicity i.education experience i.localSA off_pri aftale_afg t1_oensk_diff SDB if dummy_pref_sq ==1

//Robusthed //
generate t2_oensk_diff_test = t2_oensk_diff
recode t2_oensk_diff_test (8 9 10 11 12 13 14 =.) 


//opdeling i aldersgrupper //
generate aldersgrupper = age
recode aldersgrupper (18 19 20 21 22 23 24 =1) (25 26 27 28 29 30 31 32 33 34 = 2) (35 36 37 38 39 40 41 42 43 44 =3) (45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60=4)

//Tillid til SF//
recode Q20_1 (1=0) (2=1) (3=2) (4=2) (5=3) (6=4) (7=5) (8=6) (9=7) (10=8) (11=9) (12=10)
recode Q20_2 (1=0) (2=1) (3=2) (4=2) (5=3) (6=4) (7=5) (8=6) (9=7) (10=8) (11=9) (12=10)
recode Q20_3 (1=0) (2=1) (3=2) (4=2) (5=3) (6=4) (7=5) (8=6) (9=7) (10=8) (11=9) (12=10)
recode Q20_4 (1=0) (2=1) (3=2) (4=2) (5=3) (6=4) (7=5) (8=6) (9=7) (10=8) (11=9) (12=10)
recode Q20_5 (1=0) (2=1) (3=2) (4=2) (5=3) (6=4) (7=5) (8=6) (9=7) (10=8) (11=9) (12=10)

factor Q20_1 Q20_2 Q20_3 Q20_4 Q20_5, pcf
alpha Q20_1 Q20_2 Q20_3 Q20_4 Q20_5, item casewise

generate tillid =((Q20_1+Q20_2+Q20_3+Q20_4+Q20_5)/5) 
